// +----------------------------------------------------------------------
// | Project:   Android-Commons
// +----------------------------------------------------------------------
// | CreateTime: 12/10/2015 13:57 下午
// +----------------------------------------------------------------------
// | Author:     xab(xab@xabad.cn)
// +----------------------------------------------------------------------
// | Description:
// +----------------------------------------------------------------------
package cn.xabad.commons.sample.ui.activity;

import android.os.Bundle;
import android.widget.TextView;
import butterknife.Bind;
import cn.xabad.commons.sample.R;
import cn.xabad.commons.sample.component.AppComponent;
import cn.xabad.commons.sample.component.DaggerMainComponent;
import cn.xabad.commons.sample.modules.MainModule;
import cn.xabad.commons.sample.ui.commons.BaseActivity;
import cn.xabad.commons.sample.ui.features.IMain;
import cn.xabad.commons.sample.ui.presenter.MainPresenter;
import com.jakewharton.rxbinding.view.RxView;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;

/**
 * DESC   :
 * AUTHOR : Xabad
 */
public class MainActivity extends BaseActivity implements IMain {

    @Inject MainPresenter presenter;
    @Bind(R.id.tv_main_regist) TextView tvMainRegist;
    @Bind(R.id.tv_main_login) TextView tvMainLogin;
    @Bind(R.id.tv_main_userme) TextView tvMainUserme;


    @Override
    public void getArgs(Bundle bundle) {

    }


    @Override
    public int setView() {
        return R.layout.activity_main;
    }


    @Override
    public void initView() {
    }


    @Override
    public void setListener() {
        RxView.clicks(tvMainRegist)
              .throttleFirst(500, TimeUnit.MILLISECONDS)
              .subscribe(aVoid -> {
                  presenter.regist();
              });
        RxView.clicks(tvMainLogin)
              .throttleFirst(500, TimeUnit.MILLISECONDS)
              .subscribe(aVoid -> {
                  presenter.login();
              });
        RxView.clicks(tvMainUserme)
              .throttleFirst(500, TimeUnit.MILLISECONDS)
              .subscribe(aVoid -> {
                  presenter.userme();
              });
    }


    @Override
    protected void setupComponent(AppComponent appComponent) {
        DaggerMainComponent.builder()
                           .appComponent(appComponent)
                           .mainModule(new MainModule(this))
                           .build()
                           .inject(this);
    }

}
